package com.explorati.design_pattern.creational.builder.v2;

/**
 * 链式调用实现建造者模式：更常用
 * 
 * @author explorati
 *
 */
public class Course {

	private String courseName;
	private String coursePPT;
	private String courseVideo;
	private String courseArticle;

	// question && answer
	private String courseQA;

	public Course(CourseBuilder courseBuilder) {
		this.courseName = courseBuilder.courseName;
		this.coursePPT = courseBuilder.coursePPT;
		this.courseArticle = courseBuilder.courseArticle;
		this.courseVideo = courseBuilder.courseVideo;
		this.courseQA = courseBuilder.courseQA;
	}

	@Override
	public String toString() {
		return "Course [courseName=" + courseName + ", coursePPT=" + coursePPT + ", courseVideo=" + courseVideo
				+ ", courseArticle=" + courseArticle + ", courseQA=" + courseQA + "]";
	}

	/*
	 * 内部静态类 课程建造者的链式实现
	 */
	public static class CourseBuilder {
		private String courseName;
		private String coursePPT;
		private String courseVideo;
		private String courseArticle;

		// question && answer
		private String courseQA;

		public CourseBuilder buildCourseName(String courseName) {
			this.courseName = courseName;
			return this;
		}

		public CourseBuilder buildCoursePPT(String coursePPT) {
			this.coursePPT = coursePPT;
			return this;
		}

		public CourseBuilder buildCourseVideo(String courseVideo) {
			this.courseVideo = courseVideo;
			return this;
		}

		public CourseBuilder buildCourseArticle(String courseArticle) {
			this.courseArticle = courseArticle;
			return this;
		}

		public CourseBuilder buildCourseQA(String courseQA) {
			this.courseQA = courseQA;
			return this;
		}

		public Course build() {
			return new Course(this);
		}
	}
}
